package com.hyh.session;

import java.net.DatagramPacket;

import com.hyh.net.NetPlatform;
import com.hyh.net.NetPlatform.OnRecvCallback;
import com.hyh.parser.BaseParser;

public class GosSession implements OnRecvCallback {
	
	private NetPlatform netPlatform;
	private BaseParser baseParser;
	
	public GosSession() {
		baseParser = new BaseParser();
		netPlatform = new NetPlatform(this);
	}

	@Override
	public void onCallback(DatagramPacket packet) {
		DatagramPacket datagramPacket = baseParser.parse(packet);
		if(datagramPacket==null){
			return;
		}
		if(datagramPacket.getAddress()==null){
			netPlatform.sendAll(datagramPacket);
		}else{
			netPlatform.send(datagramPacket);
		}
	}
}
